<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">

<TITLE>Switch -AG[format] - generate archive name using the current
date and time</TITLE>
<link href="style.css" rel="stylesheet" type="text/css">
</HEAD>

<BODY>

<P class="title"><A NAME="HELPSwAG"></A>Switch <B>-AG[format]</B> - generate
archive name using the current date and time<hr></P>

<P>Appends the current date string to an archive name when creating
or processing an archive. Useful for daily backups.</P>

<P>Format of the appending string is defined by the optional <I>format</I>
parameter or by "YYYYMMDDHHMMSS" if this parameter is absent. The format
string may include the following characters:<br>
</P>

<TABLE>

<TR VALIGN="top">
<TD><b>Y</b></TD>
<TD>year</TD>
</TR>

<TR VALIGN="top">
<TD><b>M</b></TD>
<TD>month</TD>
</TR>

<TR VALIGN="top">
<TD><b>MMM</b></TD>
<TD>month as text string (Jan, Feb, etc.)</TD>
</TR>

<TR VALIGN="top">
<TD><b>W</b></TD>
<TD>a week number (a week starts with Monday)</TD>
</TR>

<TR VALIGN="top">
<TD><b>A</b></TD>
<TD>day of week (Monday is 1, Sunday is 7)</TD>
</TR>

<TR VALIGN="top">
<TD><b>D</b></TD>
<TD>day of month</TD>
</TR>

<TR VALIGN="top">
<TD><b>E</b></TD>
<TD>day of year</TD>
</TR>

<TR VALIGN="top">
<TD><b>H</b></TD>
<TD>hours</TD>
</TR>

<TR VALIGN="top">
<TD><b>M</b></TD>
<TD>minutes (first two 'M' after hours treated as minutes)</TD>
</TR>

<TR VALIGN="top">
<TD><b>I</b></TD>
<TD>minutes (treated as minutes regardless of hours position)</TD>
</TR>

<TR VALIGN="top">
<TD><b>S</b></TD>
<TD>seconds</TD>
</TR>

<TR VALIGN="top">
<TD><b>N</b></TD>
<TD>archive number (numeric value starting from 1).
<br>When archiving, WinRAR searches for already existing archive with
generated name and if found, increments the archive number until generating
an unused name. 'N' format character is not supported when creating
<A HREF="HELPArcVolumes.htm">volumes</A>.
<br>When performing non-archiving operations like extracting, WinRAR selects
the existing archive preceding the first unused name or sets N to 1
if no such archive exists.</TD>
</TR>
</TABLE>
<BR>

<P>Each of format string characters listed above represents only one
character added to archive name. For example, use WW for two digit
week number or YYYY to define the four digit year.</P>

<P>If the first character in the format string is '+', positions of
the date string and base archive name are exchanged, so a date will
precede an archive name.</P>

<p>If the first character in the format string is 'F', the rest of string
specifies the default format string for -ag switch. Such -agf&lt;default_format&gt;
switch has a practical value only if placed to <a href="HELPRARIni.htm">
rar.ini file</a> or <a href="HELPRARVar.htm">RARINISWITCHES environment
variable</a>. For example, if we set RARINISWITCHES environment variable to
-agfYYYY-MMM-DD, we can use -ag without a parameter with YYYY-MMM-DD format
string assumed.</p>

<P>The format string may contain optional text enclosed in '{' and
'}' characters. This text is inserted into archive name.</P>

<P>All other characters are added to an archive name without changes.</P>

<P>If you need to process an already existing archive, be careful with
-ag switch. Depending on the format string and time passed since previous
-ag use, generated and existing archive names may mismatch. In this case
WinRAR will create or open a new archive instead of processing the already
existing one. You may use <a href="HELPSwLOG.htm">-log switch</a> to write
the generated archive name to a file and then read it from file
for further processing.</P>

<h1><B>Examples</B></h1>

<ol>
  <li>use the default YYYYMMDDHHMMSS format</li>
</ol>
<blockquote>
  <p class="sample">WinRAR a -ag backup</p>
</blockquote>
<ol start="2">
  <li>use DD-MMM-YY format</li>
</ol>
<blockquote>
  <p class="sample">WinRAR t -agDD-MMM-YY backup</p>
</blockquote>
<ol start="3">
  <li>use YYYYMMDDHHMM format, place date before '<I>backup</I>' </li>
</ol>
<blockquote>
  <p class="sample"><b>WinRAR a -ag+YYYYMMDDHHMM backup</b></p>
</blockquote>
<ol start="4">
  <li>use YYYY-WW-A format, include fields description</li>
</ol>
<blockquote>
  <p class="sample"><b>WinRAR a -agYYYY{year}-WW{week}-A{wday} backup</b></p>
</blockquote>
<ol start="5">
  <li>use YYYYMMDD and the archive number. It allows to generate unique
    names even when YYYYMMDD format mask used more than once in the same
    day</li>
</ol>
<blockquote>
  <p class="sample">WinRAR a -agYYYYMMDD-NN backup</p>
</blockquote>
</BODY>
</HTML>
